home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr54 / bison118.zip / VMSGETAR.C < prev    next >
C/C++ Source or Header  |  1993-06-01  |  3KB  |  134 lines

  1. /* VMS version of getargs; Uses DCL command parsing.
  2.    Copyright (C) 1989 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18.  
  19. #include <ctype.h>
  20. #include <stdio.h>
  21. #include "files.h"
  22.  
  23. /*
  24.  *    VMS version of getargs(): Uses DCL command parsing
  25.  *        (argc and argv are ignored)
  26.  */
  27. int verboseflag;
  28. int definesflag;
  29. int debugflag;
  30. int nolinesflag;
  31. extern int fixed_outfiles;
  32.  
  33. /* Allocate storgate and initialize, since bison uses them elsewhere.  */
  34. char *spec_name_prefix;
  35. char *spec_file_prefix;
  36.  
  37. getargs(argc,argv)
  38.      int argc;
  39.      char *argv[];
  40. {
  41.   register char *cp;
  42.   static char Input_File[256];
  43.   static char output_spec[256];
  44.   extern char *infile;
  45.  
  46.   verboseflag = 0;
  47.   definesflag = 0;
  48.   debugflag = 0;
  49.   fixed_outfiles = 0;
  50.   nolinesflag = 0;
  51.   /*
  52.    *    Check for /VERBOSE qualifier
  53.    */
  54.   if (cli_present("BISON$VERBOSE")) verboseflag = 1;
  55.   /*
  56.    *    Check for /DEFINES qualifier
  57.    */
  58.   if (cli_present("BISON$DEFINES")) definesflag = 1;
  59.   /*
  60.    *    Check for /FIXED_OUTFILES qualifier
  61.    */
  62.   if (cli_present("BISON$FIXED_OUTFILES")) fixed_outfiles = 1;
  63.   /*
  64.    *    Check for /NOLINES qualifier
  65.    */
  66.   if (cli_present("BISON$NOLINES")) nolinesflag = 1;
  67.   /*
  68.    *    Check for /DEBUG qualifier
  69.    */
  70.   if (cli_present("BISON$DEBUG")) debugflag = 1;
  71.   /*
  72.    *    Get the filename
  73.    */
  74.   cli_get_value("BISON$INFILE", Input_File, sizeof(Input_File));
  75.   /*
  76.    *    Lowercaseify the input filename
  77.    */
  78.   cp = Input_File;
  79.   while(*cp)
  80.     {
  81.       if (isupper(*cp)) *cp = tolower(*cp);
  82.       cp++;
  83.     }
  84.   infile = Input_File;
  85.   /*
  86.    *    Get the output file
  87.    */
  88.   if (cli_present("BISON$OUTPUT"))
  89.     {
  90.       cli_get_value("BISON$OUTPUT", output_spec, sizeof(output_spec));
  91.       for (cp = spec_outfile = output_spec; *cp; cp++)
  92.     if (isupper(*cp))
  93.       *cp = tolower(*cp);
  94.     }
  95. }
  96.  
  97. /************        DCL PARSING ROUTINES        **********/
  98.  
  99. /*
  100.  *    See if "NAME" is present
  101.  */
  102. int
  103. cli_present(Name)
  104.      char *Name;
  105. {
  106.   struct {int Size; char *Ptr;} Descr;
  107.  
  108.   Descr.Ptr = Name;
  109.   Descr.Size = strlen(Name);
  110.   return((cli$present(&Descr) & 1) ? 1 : 0);
  111. }
  112.  
  113. /*
  114.  *    Get value of "NAME"
  115.  */
  116. int
  117. cli_get_value(Name,Buffer,Size)
  118.      char *Name;
  119.      char *Buffer;
  120. {
  121.   struct {int Size; char *Ptr;} Descr1,Descr2;
  122.  
  123.   Descr1.Ptr = Name;
  124.   Descr1.Size = strlen(Name);
  125.   Descr2.Ptr = Buffer;
  126.   Descr2.Size = Size-1;
  127.   if (cli$get_value(&Descr1,&Descr2,&Descr2.Size) & 1) {
  128.     Buffer[Descr2.Size] = 0;
  129.     return(1);
  130.   }
  131.   return(0);
  132. }
  133.  
  134.